<template>
  <head-top :loading="true">

  </head-top>
</template>
<script setup lang="ts">
import { nextTick, ref } from 'vue'
import { onLoad, onReady, onShow, onReachBottom } from "@dcloudio/uni-app";
import { payStore } from '@/store/modules/pay'
import { get_, set_, clear_ } from '@/utils'
const store = payStore()

onLoad((e) => {
  clear_('Token')
  let url = document.location.toString()
  if (url) {
    var _url = url.split('?')
    login_(_url, e)
  }
})

function login_(url: string[], Node: any) {
  if (url.length == 1) {
    store.locationFn(url)
  } else {
    let code = url[1].split('code=')[1]
    nextTick(async () => {
      const res = await store.loginReturn_(code)
      const shareUrl = ref<string | string[]>(get_('shareUrl') || '')
      if (res.code == 200) {
        if (shareUrl.value == '') {
          window.location.href = url[0] + '#' + '/pages/index/index'
        } else {
          window.location.href = url[0] + '#' + shareUrl.value
          clear_('shareUrl')
        }
      }
    })
  }


}
</script>